﻿@using System.Diagnostics
@using  Masuit.MyBlogs.Services.DTO
@using Masuit.MyBlogs.Domain.Entity
@using Masuit.Tools.Helper 
@using Masuit.Tools.Core.Net
@model Masuit.MyBlogs.Domain.Entity.PostHistoryVersion
@{
    ViewBag.Title = Model.Post.Title + "于" + Model.ModifyDate.ToString("yyyy-MM-dd HH:mm:ss") + "的历史版本：" + Model.Title;
    Layout = "~/Views/Shared/_Layout.cshtml";
    string[] colors = { "success", "info", "primary", "warning", "danger", "default", "primary" };
    Advertisement ad = ViewBag.Ads;
}
<environment names="Development">
    <link href="~/Assets/jquery.tocify/jquery.tocify.min.css" rel="stylesheet" />
    <link href="~/Assets/UEditor/third-party/SyntaxHighlighter/styles/shCore.min.css" rel="stylesheet" />
    <link href="~/Assets/share/share.css" rel="stylesheet" />
    <link href="~/Assets/highlight/css/highlight.css" rel="stylesheet" />
    <script src="~/Assets/share/jquery.qrcode.min.js"></script>
    <script src="~/Assets/share/jquery.share.min.js"></script>
    <script src="~/Assets/highlight/js/highlight.js"></script>
</environment>
<environment names="Stage,Production">
    @await Styles.RenderAsync("/bundles/article.css")
    @await Scripts.RenderAsync("/bundles/article.js")
</environment>
<div class="container">
    <ol class="cd-breadcrumb triangle">
        <li><a asp-controller="Home" asp-action="Index">首页</a></li>
        <li><a asp-controller="Home" asp-action="Post">文章列表</a></li>
        <li>@Html.ActionLink(Model.Post.Title.Length > 20 ? Model.Post.Title.Substring(0, 20) + "..." : Model.Post.Title, "Details", "Post", new { id = Model.PostId }, null)</li>
        <li><a asp-controller="Post" asp-action="History" asp-route-id="@Model.PostId">历史版本</a></li>
        <li class="current"><em>@(Model.Title.Length > 40 ? Model.Title.Substring(0, 40) + "..." : Model.Title)</em></li>
    </ol>
    <div class="wrapper-content article">
        <div class="ibox">
            <div class="ibox-content animated fadeIn">
                <main>
                    <section class="history article-content">
                        <header class="page-header">
                            <div class="text-center">
                                <a>
                                    <h2 class="padding-bot10">
                                        @Model.Title
                                    </h2>
                                </a>
                            </div>
                            <div class="row">
                                <div class="col-sm-7">
                                    <div class="padding-bot10">
                                        <span class="label label-@colors[new Random().Next() % colors.Length]">@Model.Modifier</span>修改于<span class="text-success">@Model.ModifyDate.ToString("yyyy-MM-dd HH:mm:ss")</span> |
                                        原分类：<i class="icon-map-pin"></i><a asp-controller="Home" asp-action="Category" asp-route-id="@Model.CategoryId" class="label label-@colors[new Random().Next() % colors.Length]">@Model.Category.Name</a>
                                        @if (Model.Seminar.Any())
                                        {
                                            <span> | 原所属专题：</span>
                                            var seminars = Model.Seminar;
                                            foreach (var s in seminars)
                                            {
                                                <a asp-controller="Seminar" asp-action="Index" asp-route-id="@s.SeminarId" class="label label-@colors[new Random().Next() % colors.Length]">@s.Seminar.Title</a><text> </text>
                                            }
                                        }
                                    </div>
                                </div>
                                @{
                                    if (!string.IsNullOrEmpty(Model.Label))
                                    {
                                        <div class="pull-right margin-right20">
                                            <div>
                                                @foreach (string s in Model.Label.Split(',', '，', ' '))
                                                {
                                                    if (!string.IsNullOrEmpty(s))
                                                    {
                                                        <a asp-controller="Home" asp-action="Tag" asp-route-id="@s">
                                                            <span class="label label-@colors[new Random().Next() % colors.Length]">@s</span>
                                                        </a>
                                                    }
                                                }
                                            </div>
                                        </div>
                                    }
                                }
                            </div>
                            <p class="text-focus text-center">您目前正在查看该文章的历史版本，文章的历史版本可能无法为您提供最准确及时的资讯，不具备任何参考价值，<a asp-controller="Post" asp-action="Details" asp-route-id="@Model.PostId">点击前往</a>该文章的最新版本。</p>
                        </header>
                        <article class="article" id="article">
                            @Html.Raw(Model.Content.ReplaceImgAttribute(Model.Title))
                            @if (!string.IsNullOrEmpty(Model.ProtectContent))
                            {
                                <div class="row protected">
                                    @if (string.IsNullOrEmpty(Context.Session.Get<string>("AccessViewToken")))
                                    {
                                        <p class="text-red text-center size24 margin-bot10">↓↓↓恭喜你发现镇站之宝，请注意，前方高能！非战斗人员请及时撤离，这不是演习！↓↓↓</p>
                                        <div class="col-md-6">
                                            <span class="text-red">以下内容已经隐藏，请输入验证码后查看</span>
                                            <span class="text-green">【完全免费，不收一分钱】</span>
                                            <form action="/" method="post" class="form-inline" id="code-token">
                                                <div class="input-group">
                                                    @Html.AntiForgeryToken()
                                                    <span class="input-group-addon">验证码：</span>
                                                    <input type="text" name="token" id="token" class="form-control" />
                                                    <span class="input-group-btn">
                                                        <button type="submit" class="btn btn-info">查看文章</button>
                                                    </span>
                                                </div>
                                            </form>
                                            <p class="text-green">温馨提示：将本页面分享到您的社交平台上，如QQ或微信，并保证3h之内不会删除且获得10个以上的点赞或评论后，通过站长QQ私信获取文章访问密码，<span class="text-red">获取密码后本站所有加密文章将永久开放！</span></p>
                                        </div>
                                        <div class="col-md-6">
                                            <span class="text-green">如果你曾经获取过密码，请输入您的邮箱后查看</span>
                                            <form action="/" method="post" class="form-inline" id="email-token">
                                                <div class="input-group">
                                                    @Html.AntiForgeryToken()
                                                    <span class="input-group-addon">邮箱：</span>
                                                    <input type="email" name="Email" id="email3" class="form-control" />
                                                    <span class="input-group-btn">
                                                        <button type="submit" class="btn btn-info">查看文章</button>
                                                    </span>
                                                </div>
                                            </form>
                                            <p class="text-green">温馨提示：请确保您的邮箱已经通过站长的登记，如果您未使用邮箱登记，请先联系站长获取文章密码并登记邮箱即可！</p>
                                        </div>
                                    }
                                    else
                                    {
                                        <p class="text-red text-center size20">↓↓↓以下是文章加密部分↓↓↓</p>
                                        @Html.Raw(Model.ProtectContent.ReplaceImgAttribute(Model.Title))
                                    }
                                </div>
                            }
                        </article>
                        <div id="cyReward" role="cylabs" data-use="reward"></div>
                    </section>
                </main>
                <hr />
                <section class="wow fadeInUp row size16">
                    <div class="col-xs-6">
                        前一版本：
                        @{
                            PostHistoryVersion prev = ViewBag.Prev;
                            if (prev != null)
                            {
                                <a asp-controller="Post" asp-action="HistoryVersion" asp-route-id="@prev.PostId" asp-route-hid="@prev.Id">@prev.Title</a>
                            }
                            else
                            {
                                <a>没有了</a>
                            }
                        }
                    </div>
                    <div class="col-xs-6 text-right">
                        下一版本：
                        @{
                            PostHistoryVersion next = ViewBag.Next;
                            if (next != null)
                            {
                                <a asp-controller="Post" asp-action="HistoryVersion" asp-route-id="@next.PostId" asp-route-hid="@next.Id">@next.Title</a>
                            }
                            else
                            {
                                <a>没有了</a>
                            }
                        }
                    </div>
                </section>
                @if (ad != null)
                {
                    <section class="protected">
                        <a asp-controller="Advertisement" asp-action="Redirect" asp-route-id="@ad.Id" target="_blank" id="@Stopwatch.GetTimestamp()">
                            <h3>
                                @ad.Title
                                <span class="text-red">[推广]</span>
                            </h3>

                            <div class="row padding-bot10">
                                @{
                                    string imgSrc = ad.ThumbImgUrl;
                                    if (!string.IsNullOrEmpty(imgSrc))
                                    {
                                        <div class="col-md-3">
                                            <img class="img-thumbnail img-responsive thumb" data-original="@imgSrc" alt="@ad.Title" title="@ad.Title ">
                                        </div>
                                    }
                                }
                                <div class="col-md-@(string.IsNullOrEmpty(imgSrc) ? 12 : 9)">
                                    <p>
                                        @ad.Description
                                    </p>
                                </div>
                            </div>
                        </a>
                    </section>
                }
            </div>
        </div>
    </div>
</div>
<noscript>
    <iframe src="*.htm"></iframe>
</noscript>
<script>
    $(function () {
        @if(Model.Post.DisableCopy) {
            <text>
        GlobalCopyrightProtect();
            </text>
        }
        $("#toc").show();
        var toc = $("#toc").tocify({
            selectors: ".ibox-content h3,.ibox-content h4,.ibox-content h5"
        }).data("toc-tocify");
        $(".tocify>.close").on("click", function (e) {
            $(this).parent().hide();
        });
        SyntaxHighlighter.all();
        SyntaxHighlighter.defaults['toolbar'] = false;
        $("#code-token").on("submit", function (e) {
            e.preventDefault();
            $.post("/post/CheckViewToken", $(this).serialize(), function (data) {
                if (data.Success) {
                    window.location.reload();
                } else {
                    window.notie.alert({
                        type: 3,
                        text: data.Message,
                        time: 4
                    });
                }
            });
        });
        $("#email-token").on("submit", function (e) {
            e.preventDefault();
            $.post("/post/getviewtoken", $(this).serialize(), function (data) {
                if (data.Success) {
                    window.localStorage.setItem("email", $("#email3").val());
                    window.location.reload();
                } else {
                    window.notie.alert({
                        type: 3,
                        text: data.Message,
                        time: 4
                    });
                }
            });
        });
    })
</script>